
_ls:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:
  close(fd);
}

int
main(int argc, char *argv[])
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	57                   	push   %edi
   4:	56                   	push   %esi
   5:	53                   	push   %ebx
  int i;

  if(argc < 2){
   6:	bb 01 00 00 00       	mov    $0x1,%ebx
  close(fd);
}

int
main(int argc, char *argv[])
{
   b:	83 e4 f0             	and    $0xfffffff0,%esp
   e:	83 ec 10             	sub    $0x10,%esp
  11:	8b 75 08             	mov    0x8(%ebp),%esi
  14:	8b 7d 0c             	mov    0xc(%ebp),%edi
  int i;

  if(argc < 2){
  17:	83 fe 01             	cmp    $0x1,%esi
  1a:	7e 1b                	jle    37 <main+0x37>
  1c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    ls(".");
    exit();
  }
  for(i=1; i<argc; i++)
    ls(argv[i]);
  20:	8b 04 9f             	mov    (%edi,%ebx,4),%eax

  if(argc < 2){
    ls(".");
    exit();
  }
  for(i=1; i<argc; i++)
  23:	83 c3 01             	add    $0x1,%ebx
    ls(argv[i]);
  26:	89 04 24             	mov    %eax,(%esp)
  29:	e8 c2 00 00 00       	call   f0 <ls>

  if(argc < 2){
    ls(".");
    exit();
  }
  for(i=1; i<argc; i++)
  2e:	39 f3                	cmp    %esi,%ebx
  30:	75 ee                	jne    20 <main+0x20>
    ls(argv[i]);
  exit();
  32:	e8 9d 05 00 00       	call   5d4 <exit>
main(int argc, char *argv[])
{
  int i;

  if(argc < 2){
    ls(".");
  37:	c7 04 24 2e 0a 00 00 	movl   $0xa2e,(%esp)
  3e:	e8 ad 00 00 00       	call   f0 <ls>
    exit();
  43:	e8 8c 05 00 00       	call   5d4 <exit>
  48:	90                   	nop
  49:	90                   	nop
  4a:	90                   	nop
  4b:	90                   	nop
  4c:	90                   	nop
  4d:	90                   	nop
  4e:	90                   	nop
  4f:	90                   	nop

00000050 <fmtname>:
#include "user.h"
#include "fs.h"

char*
fmtname(char *path)
{
  50:	56                   	push   %esi
  51:	53                   	push   %ebx
  52:	83 ec 14             	sub    $0x14,%esp
  55:	8b 5c 24 20          	mov    0x20(%esp),%ebx
  static char buf[DIRSIZ+1];
  char *p;
  
  // Find first character after last slash.
  for(p=path+strlen(path); p >= path && *p != '/'; p--)
  59:	89 1c 24             	mov    %ebx,(%esp)
  5c:	e8 8f 03 00 00       	call   3f0 <strlen>
  61:	01 d8                	add    %ebx,%eax
  63:	73 0d                	jae    72 <fmtname+0x22>
  65:	eb 10                	jmp    77 <fmtname+0x27>
  67:	90                   	nop
  68:	83 e8 01             	sub    $0x1,%eax
  6b:	39 c3                	cmp    %eax,%ebx
  6d:	8d 76 00             	lea    0x0(%esi),%esi
  70:	77 05                	ja     77 <fmtname+0x27>
  72:	80 38 2f             	cmpb   $0x2f,(%eax)
  75:	75 f1                	jne    68 <fmtname+0x18>
    ;
  p++;
  77:	8d 58 01             	lea    0x1(%eax),%ebx
  
  // Return blank-padded name.
  if(strlen(p) >= DIRSIZ)
  7a:	89 1c 24             	mov    %ebx,(%esp)
  7d:	e8 6e 03 00 00       	call   3f0 <strlen>
  82:	83 f8 0d             	cmp    $0xd,%eax
  85:	77 53                	ja     da <fmtname+0x8a>
    return p;
  memmove(buf, p, strlen(p));
  87:	89 1c 24             	mov    %ebx,(%esp)
  8a:	e8 61 03 00 00       	call   3f0 <strlen>
  8f:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  93:	c7 04 24 3c 0d 00 00 	movl   $0xd3c,(%esp)
  9a:	89 44 24 08          	mov    %eax,0x8(%esp)
  9e:	e8 cd 04 00 00       	call   570 <memmove>
  memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
  a3:	89 1c 24             	mov    %ebx,(%esp)
  a6:	e8 45 03 00 00       	call   3f0 <strlen>
  ab:	89 1c 24             	mov    %ebx,(%esp)
  return buf;
  ae:	bb 3c 0d 00 00       	mov    $0xd3c,%ebx
  
  // Return blank-padded name.
  if(strlen(p) >= DIRSIZ)
    return p;
  memmove(buf, p, strlen(p));
  memset(buf+strlen(p), ' ', DIRSIZ-strlen(p));
  b3:	89 c6                	mov    %eax,%esi
  b5:	e8 36 03 00 00       	call   3f0 <strlen>
  ba:	ba 0e 00 00 00       	mov    $0xe,%edx
  bf:	29 f2                	sub    %esi,%edx
  c1:	89 54 24 08          	mov    %edx,0x8(%esp)
  c5:	c7 44 24 04 20 00 00 	movl   $0x20,0x4(%esp)
  cc:	00 
  cd:	05 3c 0d 00 00       	add    $0xd3c,%eax
  d2:	89 04 24             	mov    %eax,(%esp)
  d5:	e8 36 03 00 00       	call   410 <memset>
  return buf;
}
  da:	83 c4 14             	add    $0x14,%esp
  dd:	89 d8                	mov    %ebx,%eax
  df:	5b                   	pop    %ebx
  e0:	5e                   	pop    %esi
  e1:	c3                   	ret    
  e2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  e9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000000f0 <ls>:

void
ls(char *path)
{
  f0:	81 ec 8c 02 00 00    	sub    $0x28c,%esp
  f6:	89 bc 24 84 02 00 00 	mov    %edi,0x284(%esp)
  fd:	8b bc 24 90 02 00 00 	mov    0x290(%esp),%edi
 104:	89 9c 24 7c 02 00 00 	mov    %ebx,0x27c(%esp)
 10b:	89 b4 24 80 02 00 00 	mov    %esi,0x280(%esp)
 112:	89 ac 24 88 02 00 00 	mov    %ebp,0x288(%esp)
  char buf[512], *p;
  int fd;
  struct dirent de;
  struct statt st;
  
  if((fd = open(path, 0)) < 0){
 119:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 120:	00 
 121:	89 3c 24             	mov    %edi,(%esp)
 124:	e8 eb 04 00 00       	call   614 <open>
 129:	85 c0                	test   %eax,%eax
 12b:	89 c3                	mov    %eax,%ebx
 12d:	0f 88 cd 01 00 00    	js     300 <ls+0x210>
    printf(2, "ls: cannot open %s\n", path);
    return;
  }
  
  if(fstat(fd, &st) < 0){
 133:	8d b4 24 4c 02 00 00 	lea    0x24c(%esp),%esi
 13a:	89 74 24 04          	mov    %esi,0x4(%esp)
 13e:	89 04 24             	mov    %eax,(%esp)
 141:	e8 e6 04 00 00       	call   62c <fstat>
 146:	85 c0                	test   %eax,%eax
 148:	0f 88 f2 01 00 00    	js     340 <ls+0x250>
    printf(2, "ls: cannot stat %s\n", path);
    close(fd);
    return;
  }
  
  switch(st.type){
 14e:	0f b7 84 24 4c 02 00 	movzwl 0x24c(%esp),%eax
 155:	00 
 156:	66 83 f8 01          	cmp    $0x1,%ax
 15a:	74 74                	je     1d0 <ls+0xe0>
 15c:	66 83 f8 02          	cmp    $0x2,%ax
 160:	74 2e                	je     190 <ls+0xa0>
      }
      printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
    }
    break;
  }
  close(fd);
 162:	89 1c 24             	mov    %ebx,(%esp)
 165:	e8 92 04 00 00       	call   5fc <close>
}
 16a:	8b 9c 24 7c 02 00 00 	mov    0x27c(%esp),%ebx
 171:	8b b4 24 80 02 00 00 	mov    0x280(%esp),%esi
 178:	8b bc 24 84 02 00 00 	mov    0x284(%esp),%edi
 17f:	8b ac 24 88 02 00 00 	mov    0x288(%esp),%ebp
 186:	81 c4 8c 02 00 00    	add    $0x28c,%esp
 18c:	c3                   	ret    
 18d:	8d 76 00             	lea    0x0(%esi),%esi
    return;
  }
  
  switch(st.type){
  case T_FILE:
    printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
 190:	8b ac 24 5c 02 00 00 	mov    0x25c(%esp),%ebp
 197:	8b b4 24 54 02 00 00 	mov    0x254(%esp),%esi
 19e:	89 3c 24             	mov    %edi,(%esp)
 1a1:	e8 aa fe ff ff       	call   50 <fmtname>
 1a6:	89 6c 24 14          	mov    %ebp,0x14(%esp)
 1aa:	89 74 24 10          	mov    %esi,0x10(%esp)
 1ae:	c7 44 24 0c 02 00 00 	movl   $0x2,0xc(%esp)
 1b5:	00 
 1b6:	c7 44 24 04 0e 0a 00 	movl   $0xa0e,0x4(%esp)
 1bd:	00 
 1be:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 1c5:	89 44 24 08          	mov    %eax,0x8(%esp)
 1c9:	e8 52 05 00 00       	call   720 <printf>
    break;
 1ce:	eb 92                	jmp    162 <ls+0x72>
  
  case T_DIR:
    if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
 1d0:	89 3c 24             	mov    %edi,(%esp)
 1d3:	e8 18 02 00 00       	call   3f0 <strlen>
 1d8:	83 c0 10             	add    $0x10,%eax
 1db:	3d 00 02 00 00       	cmp    $0x200,%eax
 1e0:	0f 87 fa 00 00 00    	ja     2e0 <ls+0x1f0>
      printf(1, "ls: path too long\n");
      break;
    }
    strcpy(buf, path);
 1e6:	8d 6c 24 4c          	lea    0x4c(%esp),%ebp
 1ea:	89 7c 24 04          	mov    %edi,0x4(%esp)
 1ee:	8d bc 24 60 02 00 00 	lea    0x260(%esp),%edi
 1f5:	89 2c 24             	mov    %ebp,(%esp)
 1f8:	e8 73 01 00 00       	call   370 <strcpy>
    p = buf+strlen(buf);
 1fd:	89 2c 24             	mov    %ebp,(%esp)
 200:	e8 eb 01 00 00       	call   3f0 <strlen>
 205:	01 e8                	add    %ebp,%eax
 207:	89 44 24 34          	mov    %eax,0x34(%esp)
    *p++ = '/';
 20b:	c6 00 2f             	movb   $0x2f,(%eax)
 20e:	83 c0 01             	add    $0x1,%eax
 211:	89 44 24 3c          	mov    %eax,0x3c(%esp)
 215:	8d 76 00             	lea    0x0(%esi),%esi
    while(read(fd, &de, sizeof(de)) == sizeof(de)){
 218:	c7 44 24 08 10 00 00 	movl   $0x10,0x8(%esp)
 21f:	00 
 220:	89 7c 24 04          	mov    %edi,0x4(%esp)
 224:	89 1c 24             	mov    %ebx,(%esp)
 227:	e8 c0 03 00 00       	call   5ec <read>
 22c:	83 f8 10             	cmp    $0x10,%eax
 22f:	0f 85 2d ff ff ff    	jne    162 <ls+0x72>
      if(de.inum == 0)
 235:	66 83 bc 24 60 02 00 	cmpw   $0x0,0x260(%esp)
 23c:	00 00 
 23e:	74 d8                	je     218 <ls+0x128>
        continue;
      memmove(p, de.name, DIRSIZ);
 240:	8b 4c 24 3c          	mov    0x3c(%esp),%ecx
 244:	8d 84 24 62 02 00 00 	lea    0x262(%esp),%eax
 24b:	c7 44 24 08 0e 00 00 	movl   $0xe,0x8(%esp)
 252:	00 
 253:	89 44 24 04          	mov    %eax,0x4(%esp)
 257:	89 0c 24             	mov    %ecx,(%esp)
 25a:	e8 11 03 00 00       	call   570 <memmove>
      p[DIRSIZ] = 0;
 25f:	8b 4c 24 34          	mov    0x34(%esp),%ecx
 263:	c6 41 0f 00          	movb   $0x0,0xf(%ecx)
      if(stat(buf, &st) < 0){
 267:	89 74 24 04          	mov    %esi,0x4(%esp)
 26b:	89 2c 24             	mov    %ebp,(%esp)
 26e:	e8 5d 02 00 00       	call   4d0 <stat>
 273:	85 c0                	test   %eax,%eax
 275:	0f 88 a5 00 00 00    	js     320 <ls+0x230>
        printf(1, "ls: cannot stat %s\n", buf);
        continue;
      }
      printf(1, "%s %d %d %d\n", fmtname(buf), st.type, st.ino, st.size);
 27b:	8b 8c 24 5c 02 00 00 	mov    0x25c(%esp),%ecx
 282:	0f bf 94 24 4c 02 00 	movswl 0x24c(%esp),%edx
 289:	00 
 28a:	8b 84 24 54 02 00 00 	mov    0x254(%esp),%eax
 291:	89 2c 24             	mov    %ebp,(%esp)
 294:	89 4c 24 30          	mov    %ecx,0x30(%esp)
 298:	89 54 24 2c          	mov    %edx,0x2c(%esp)
 29c:	89 44 24 38          	mov    %eax,0x38(%esp)
 2a0:	e8 ab fd ff ff       	call   50 <fmtname>
 2a5:	8b 4c 24 30          	mov    0x30(%esp),%ecx
 2a9:	8b 54 24 2c          	mov    0x2c(%esp),%edx
 2ad:	c7 44 24 04 0e 0a 00 	movl   $0xa0e,0x4(%esp)
 2b4:	00 
 2b5:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 2bc:	89 4c 24 14          	mov    %ecx,0x14(%esp)
 2c0:	8b 4c 24 38          	mov    0x38(%esp),%ecx
 2c4:	89 54 24 0c          	mov    %edx,0xc(%esp)
 2c8:	89 44 24 08          	mov    %eax,0x8(%esp)
 2cc:	89 4c 24 10          	mov    %ecx,0x10(%esp)
 2d0:	e8 4b 04 00 00       	call   720 <printf>
 2d5:	e9 3e ff ff ff       	jmp    218 <ls+0x128>
 2da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
    break;
  
  case T_DIR:
    if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
      printf(1, "ls: path too long\n");
 2e0:	c7 44 24 04 1b 0a 00 	movl   $0xa1b,0x4(%esp)
 2e7:	00 
 2e8:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 2ef:	e8 2c 04 00 00       	call   720 <printf>
      break;
 2f4:	e9 69 fe ff ff       	jmp    162 <ls+0x72>
 2f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  int fd;
  struct dirent de;
  struct statt st;
  
  if((fd = open(path, 0)) < 0){
    printf(2, "ls: cannot open %s\n", path);
 300:	89 7c 24 08          	mov    %edi,0x8(%esp)
 304:	c7 44 24 04 e6 09 00 	movl   $0x9e6,0x4(%esp)
 30b:	00 
 30c:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
 313:	e8 08 04 00 00       	call   720 <printf>
    return;
 318:	e9 4d fe ff ff       	jmp    16a <ls+0x7a>
 31d:	8d 76 00             	lea    0x0(%esi),%esi
      if(de.inum == 0)
        continue;
      memmove(p, de.name, DIRSIZ);
      p[DIRSIZ] = 0;
      if(stat(buf, &st) < 0){
        printf(1, "ls: cannot stat %s\n", buf);
 320:	89 6c 24 08          	mov    %ebp,0x8(%esp)
 324:	c7 44 24 04 fa 09 00 	movl   $0x9fa,0x4(%esp)
 32b:	00 
 32c:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 333:	e8 e8 03 00 00       	call   720 <printf>
        continue;
 338:	e9 db fe ff ff       	jmp    218 <ls+0x128>
 33d:	8d 76 00             	lea    0x0(%esi),%esi
    printf(2, "ls: cannot open %s\n", path);
    return;
  }
  
  if(fstat(fd, &st) < 0){
    printf(2, "ls: cannot stat %s\n", path);
 340:	89 7c 24 08          	mov    %edi,0x8(%esp)
 344:	c7 44 24 04 fa 09 00 	movl   $0x9fa,0x4(%esp)
 34b:	00 
 34c:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
 353:	e8 c8 03 00 00       	call   720 <printf>
    close(fd);
 358:	89 1c 24             	mov    %ebx,(%esp)
 35b:	e8 9c 02 00 00       	call   5fc <close>
    return;
 360:	e9 05 fe ff ff       	jmp    16a <ls+0x7a>
 365:	90                   	nop
 366:	90                   	nop
 367:	90                   	nop
 368:	90                   	nop
 369:	90                   	nop
 36a:	90                   	nop
 36b:	90                   	nop
 36c:	90                   	nop
 36d:	90                   	nop
 36e:	90                   	nop
 36f:	90                   	nop

00000370 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 370:	53                   	push   %ebx
 371:	8b 44 24 08          	mov    0x8(%esp),%eax
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 375:	31 d2                	xor    %edx,%edx
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 377:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
 37b:	90                   	nop
 37c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 380:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
 384:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 387:	83 c2 01             	add    $0x1,%edx
 38a:	84 c9                	test   %cl,%cl
 38c:	75 f2                	jne    380 <strcpy+0x10>
    ;
  return os;
}
 38e:	5b                   	pop    %ebx
 38f:	c3                   	ret    

00000390 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 390:	56                   	push   %esi
 391:	53                   	push   %ebx
 392:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
 396:	8b 54 24 10          	mov    0x10(%esp),%edx
  while(*p && *p == *q)
 39a:	0f b6 01             	movzbl (%ecx),%eax
 39d:	0f b6 1a             	movzbl (%edx),%ebx
 3a0:	84 c0                	test   %al,%al
 3a2:	74 24                	je     3c8 <strcmp+0x38>
 3a4:	38 d8                	cmp    %bl,%al
 3a6:	74 11                	je     3b9 <strcmp+0x29>
 3a8:	eb 2e                	jmp    3d8 <strcmp+0x48>
 3aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 3b0:	83 c1 01             	add    $0x1,%ecx
 3b3:	38 d8                	cmp    %bl,%al
 3b5:	75 21                	jne    3d8 <strcmp+0x48>
    p++, q++;
 3b7:	89 f2                	mov    %esi,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 3b9:	0f b6 41 01          	movzbl 0x1(%ecx),%eax
    p++, q++;
 3bd:	8d 72 01             	lea    0x1(%edx),%esi
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 3c0:	0f b6 5a 01          	movzbl 0x1(%edx),%ebx
 3c4:	84 c0                	test   %al,%al
 3c6:	75 e8                	jne    3b0 <strcmp+0x20>
    p++, q++;
  return (uchar)*p - (uchar)*q;
 3c8:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 3cb:	31 c0                	xor    %eax,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 3cd:	29 d8                	sub    %ebx,%eax
}
 3cf:	5b                   	pop    %ebx
 3d0:	5e                   	pop    %esi
 3d1:	c3                   	ret    
 3d2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
    p++, q++;
  return (uchar)*p - (uchar)*q;
 3d8:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 3db:	0f b6 c0             	movzbl %al,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 3de:	29 d8                	sub    %ebx,%eax
}
 3e0:	5b                   	pop    %ebx
 3e1:	5e                   	pop    %esi
 3e2:	c3                   	ret    
 3e3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 3e9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000003f0 <strlen>:

uint
strlen(char *s)
{
 3f0:	8b 4c 24 04          	mov    0x4(%esp),%ecx
  int n;

  for(n = 0; s[n]; n++)
 3f4:	31 c0                	xor    %eax,%eax
 3f6:	80 39 00             	cmpb   $0x0,(%ecx)
 3f9:	74 10                	je     40b <strlen+0x1b>
 3fb:	31 d2                	xor    %edx,%edx
 3fd:	8d 76 00             	lea    0x0(%esi),%esi
 400:	83 c2 01             	add    $0x1,%edx
 403:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
 407:	89 d0                	mov    %edx,%eax
 409:	75 f5                	jne    400 <strlen+0x10>
    ;
  return n;
}
 40b:	f3 c3                	repz ret 
 40d:	8d 76 00             	lea    0x0(%esi),%esi

00000410 <memset>:

void*
memset(void *dst, int c, uint n)
{
 410:	57                   	push   %edi
 411:	8b 54 24 08          	mov    0x8(%esp),%edx
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
 415:	8b 4c 24 10          	mov    0x10(%esp),%ecx
 419:	8b 44 24 0c          	mov    0xc(%esp),%eax
 41d:	89 d7                	mov    %edx,%edi
 41f:	fc                   	cld    
 420:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
 422:	89 d0                	mov    %edx,%eax
 424:	5f                   	pop    %edi
 425:	c3                   	ret    
 426:	8d 76 00             	lea    0x0(%esi),%esi
 429:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000430 <strchr>:

char*
strchr(const char *s, char c)
{
 430:	8b 44 24 04          	mov    0x4(%esp),%eax
 434:	0f b6 4c 24 08       	movzbl 0x8(%esp),%ecx
  for(; *s; s++)
 439:	0f b6 10             	movzbl (%eax),%edx
 43c:	84 d2                	test   %dl,%dl
 43e:	74 1d                	je     45d <strchr+0x2d>
    if(*s == c)
 440:	38 ca                	cmp    %cl,%dl
 442:	75 0e                	jne    452 <strchr+0x22>
 444:	eb 1c                	jmp    462 <strchr+0x32>
 446:	66 90                	xchg   %ax,%ax
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 448:	83 c0 01             	add    $0x1,%eax
    if(*s == c)
 44b:	38 ca                	cmp    %cl,%dl
 44d:	8d 76 00             	lea    0x0(%esi),%esi
 450:	74 0e                	je     460 <strchr+0x30>
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 452:	0f b6 50 01          	movzbl 0x1(%eax),%edx
 456:	84 d2                	test   %dl,%dl
 458:	75 ee                	jne    448 <strchr+0x18>
    if(*s == c)
      return (char*) s;
  return 0;
 45a:	31 c0                	xor    %eax,%eax
 45c:	c3                   	ret    
 45d:	31 c0                	xor    %eax,%eax
 45f:	90                   	nop
}
 460:	f3 c3                	repz ret 
 462:	f3 c3                	repz ret 
 464:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 46a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00000470 <gets>:

char*
gets(char *buf, int max)
{
 470:	55                   	push   %ebp
 471:	57                   	push   %edi
 472:	56                   	push   %esi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 473:	31 f6                	xor    %esi,%esi
  return 0;
}

char*
gets(char *buf, int max)
{
 475:	53                   	push   %ebx
 476:	83 ec 2c             	sub    $0x2c,%esp
 479:	8b 7c 24 40          	mov    0x40(%esp),%edi
 47d:	8b 6c 24 44          	mov    0x44(%esp),%ebp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 481:	eb 38                	jmp    4bb <gets+0x4b>
 483:	90                   	nop
 484:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    cc = read(0, &c, 1);
 488:	8d 44 24 1f          	lea    0x1f(%esp),%eax
 48c:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 493:	00 
 494:	89 44 24 04          	mov    %eax,0x4(%esp)
 498:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 49f:	e8 48 01 00 00       	call   5ec <read>
    if(cc < 1)
 4a4:	85 c0                	test   %eax,%eax
 4a6:	7e 1a                	jle    4c2 <gets+0x52>
      break;
    buf[i++] = c;
 4a8:	0f b6 44 24 1f       	movzbl 0x1f(%esp),%eax
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 4ad:	89 de                	mov    %ebx,%esi
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 4af:	3c 0d                	cmp    $0xd,%al

  for(i=0; i+1 < max; ){
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
 4b1:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
 4b5:	74 0b                	je     4c2 <gets+0x52>
 4b7:	3c 0a                	cmp    $0xa,%al
 4b9:	74 07                	je     4c2 <gets+0x52>
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 4bb:	8d 5e 01             	lea    0x1(%esi),%ebx
 4be:	39 eb                	cmp    %ebp,%ebx
 4c0:	7c c6                	jl     488 <gets+0x18>
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
 4c2:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
 4c6:	83 c4 2c             	add    $0x2c,%esp
 4c9:	89 f8                	mov    %edi,%eax
 4cb:	5b                   	pop    %ebx
 4cc:	5e                   	pop    %esi
 4cd:	5f                   	pop    %edi
 4ce:	5d                   	pop    %ebp
 4cf:	c3                   	ret    

000004d0 <stat>:

int
stat(char *n, struct statt *st)
{
 4d0:	83 ec 1c             	sub    $0x1c,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 4d3:	8b 44 24 20          	mov    0x20(%esp),%eax
  return buf;
}

int
stat(char *n, struct statt *st)
{
 4d7:	89 5c 24 14          	mov    %ebx,0x14(%esp)
 4db:	89 74 24 18          	mov    %esi,0x18(%esp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
 4df:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 4e4:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 4eb:	00 
 4ec:	89 04 24             	mov    %eax,(%esp)
 4ef:	e8 20 01 00 00       	call   614 <open>
  if(fd < 0)
 4f4:	85 c0                	test   %eax,%eax
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 4f6:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
 4f8:	78 1a                	js     514 <stat+0x44>
    return -1;
  r = fstat(fd, st);
 4fa:	8b 44 24 24          	mov    0x24(%esp),%eax
 4fe:	89 1c 24             	mov    %ebx,(%esp)
 501:	89 44 24 04          	mov    %eax,0x4(%esp)
 505:	e8 22 01 00 00       	call   62c <fstat>
  close(fd);
 50a:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
 50d:	89 c6                	mov    %eax,%esi
  close(fd);
 50f:	e8 e8 00 00 00       	call   5fc <close>
  return r;
}
 514:	89 f0                	mov    %esi,%eax
 516:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 51a:	8b 74 24 18          	mov    0x18(%esp),%esi
 51e:	83 c4 1c             	add    $0x1c,%esp
 521:	c3                   	ret    
 522:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 529:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000530 <atoi>:

int
atoi(const char *s)
{
 530:	53                   	push   %ebx
 531:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  int n;

  n = 0;
 535:	31 c0                	xor    %eax,%eax
  while('0' <= *s && *s <= '9')
 537:	0f b6 11             	movzbl (%ecx),%edx
 53a:	8d 5a d0             	lea    -0x30(%edx),%ebx
 53d:	80 fb 09             	cmp    $0x9,%bl
 540:	77 1e                	ja     560 <atoi+0x30>
 542:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    n = n*10 + *s++ - '0';
 548:	0f be d2             	movsbl %dl,%edx
 54b:	83 c1 01             	add    $0x1,%ecx
 54e:	8d 04 80             	lea    (%eax,%eax,4),%eax
 551:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 555:	0f b6 11             	movzbl (%ecx),%edx
 558:	8d 5a d0             	lea    -0x30(%edx),%ebx
 55b:	80 fb 09             	cmp    $0x9,%bl
 55e:	76 e8                	jbe    548 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
 560:	5b                   	pop    %ebx
 561:	c3                   	ret    
 562:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 569:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000570 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 570:	56                   	push   %esi
 571:	53                   	push   %ebx
 572:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 576:	8b 44 24 0c          	mov    0xc(%esp),%eax
 57a:	8b 74 24 10          	mov    0x10(%esp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 57e:	85 db                	test   %ebx,%ebx
 580:	7e 14                	jle    596 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
 582:	31 d2                	xor    %edx,%edx
 584:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
 588:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 58c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 58f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 592:	39 da                	cmp    %ebx,%edx
 594:	75 f2                	jne    588 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
 596:	5b                   	pop    %ebx
 597:	5e                   	pop    %esi
 598:	c3                   	ret    
 599:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

000005a0 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 5a0:	56                   	push   %esi
 5a1:	53                   	push   %ebx
 5a2:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 5a6:	8b 44 24 0c          	mov    0xc(%esp),%eax
 5aa:	8b 74 24 10          	mov    0x10(%esp),%esi
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 5ae:	85 db                	test   %ebx,%ebx
 5b0:	7e 14                	jle    5c6 <memcpy+0x26>
 5b2:	31 d2                	xor    %edx,%edx
 5b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    *dst++ = *src++;
 5b8:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 5bc:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 5bf:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 5c2:	39 da                	cmp    %ebx,%edx
 5c4:	75 f2                	jne    5b8 <memcpy+0x18>

void *
memcpy(void *dst, const void *src, uint n)
{
  return memmove(dst, src, n);
}
 5c6:	5b                   	pop    %ebx
 5c7:	5e                   	pop    %esi
 5c8:	c3                   	ret    
 5c9:	90                   	nop
 5ca:	90                   	nop
 5cb:	90                   	nop

000005cc <fork>:
 5cc:	b8 01 00 00 00       	mov    $0x1,%eax
 5d1:	cd 40                	int    $0x40
 5d3:	c3                   	ret    

000005d4 <exit>:
 5d4:	b8 02 00 00 00       	mov    $0x2,%eax
 5d9:	cd 40                	int    $0x40
 5db:	c3                   	ret    

000005dc <wait>:
 5dc:	b8 03 00 00 00       	mov    $0x3,%eax
 5e1:	cd 40                	int    $0x40
 5e3:	c3                   	ret    

000005e4 <pipe>:
 5e4:	b8 04 00 00 00       	mov    $0x4,%eax
 5e9:	cd 40                	int    $0x40
 5eb:	c3                   	ret    

000005ec <read>:
 5ec:	b8 06 00 00 00       	mov    $0x6,%eax
 5f1:	cd 40                	int    $0x40
 5f3:	c3                   	ret    

000005f4 <write>:
 5f4:	b8 05 00 00 00       	mov    $0x5,%eax
 5f9:	cd 40                	int    $0x40
 5fb:	c3                   	ret    

000005fc <close>:
 5fc:	b8 07 00 00 00       	mov    $0x7,%eax
 601:	cd 40                	int    $0x40
 603:	c3                   	ret    

00000604 <kill>:
 604:	b8 08 00 00 00       	mov    $0x8,%eax
 609:	cd 40                	int    $0x40
 60b:	c3                   	ret    

0000060c <exec>:
 60c:	b8 09 00 00 00       	mov    $0x9,%eax
 611:	cd 40                	int    $0x40
 613:	c3                   	ret    

00000614 <open>:
 614:	b8 0a 00 00 00       	mov    $0xa,%eax
 619:	cd 40                	int    $0x40
 61b:	c3                   	ret    

0000061c <mknod>:
 61c:	b8 0b 00 00 00       	mov    $0xb,%eax
 621:	cd 40                	int    $0x40
 623:	c3                   	ret    

00000624 <unlink>:
 624:	b8 0c 00 00 00       	mov    $0xc,%eax
 629:	cd 40                	int    $0x40
 62b:	c3                   	ret    

0000062c <fstat>:
 62c:	b8 0d 00 00 00       	mov    $0xd,%eax
 631:	cd 40                	int    $0x40
 633:	c3                   	ret    

00000634 <link>:
 634:	b8 0e 00 00 00       	mov    $0xe,%eax
 639:	cd 40                	int    $0x40
 63b:	c3                   	ret    

0000063c <mkdir>:
 63c:	b8 0f 00 00 00       	mov    $0xf,%eax
 641:	cd 40                	int    $0x40
 643:	c3                   	ret    

00000644 <chdir>:
 644:	b8 10 00 00 00       	mov    $0x10,%eax
 649:	cd 40                	int    $0x40
 64b:	c3                   	ret    

0000064c <dup>:
 64c:	b8 11 00 00 00       	mov    $0x11,%eax
 651:	cd 40                	int    $0x40
 653:	c3                   	ret    

00000654 <getpid>:
 654:	b8 12 00 00 00       	mov    $0x12,%eax
 659:	cd 40                	int    $0x40
 65b:	c3                   	ret    

0000065c <sbrk>:
 65c:	b8 13 00 00 00       	mov    $0x13,%eax
 661:	cd 40                	int    $0x40
 663:	c3                   	ret    

00000664 <sleep>:
 664:	b8 14 00 00 00       	mov    $0x14,%eax
 669:	cd 40                	int    $0x40
 66b:	c3                   	ret    
 66c:	90                   	nop
 66d:	90                   	nop
 66e:	90                   	nop
 66f:	90                   	nop

00000670 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
 670:	83 ec 2c             	sub    $0x2c,%esp
 673:	88 54 24 1c          	mov    %dl,0x1c(%esp)
  write(fd, &c, 1);
 677:	8d 54 24 1c          	lea    0x1c(%esp),%edx
 67b:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 682:	00 
 683:	89 54 24 04          	mov    %edx,0x4(%esp)
 687:	89 04 24             	mov    %eax,(%esp)
 68a:	e8 65 ff ff ff       	call   5f4 <write>
}
 68f:	83 c4 2c             	add    $0x2c,%esp
 692:	c3                   	ret    
 693:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 699:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000006a0 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 6a0:	57                   	push   %edi
 6a1:	56                   	push   %esi
 6a2:	53                   	push   %ebx
 6a3:	89 c3                	mov    %eax,%ebx
 6a5:	83 ec 10             	sub    $0x10,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 6a8:	8b 44 24 20          	mov    0x20(%esp),%eax
 6ac:	85 c0                	test   %eax,%eax
 6ae:	74 60                	je     710 <printint+0x70>
 6b0:	89 d0                	mov    %edx,%eax
 6b2:	c1 e8 1f             	shr    $0x1f,%eax
 6b5:	84 c0                	test   %al,%al
 6b7:	74 57                	je     710 <printint+0x70>
    neg = 1;
    x = -xx;
 6b9:	89 d0                	mov    %edx,%eax
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
 6bb:	bf 01 00 00 00       	mov    $0x1,%edi
    x = -xx;
 6c0:	f7 d8                	neg    %eax
  } else {
    x = xx;
  }

  i = 0;
 6c2:	31 f6                	xor    %esi,%esi
 6c4:	eb 04                	jmp    6ca <printint+0x2a>
 6c6:	66 90                	xchg   %ax,%ax
  do{
    buf[i++] = digits[x % base];
 6c8:	89 d6                	mov    %edx,%esi
 6ca:	31 d2                	xor    %edx,%edx
 6cc:	f7 f1                	div    %ecx
 6ce:	0f b6 92 37 0a 00 00 	movzbl 0xa37(%edx),%edx
  }while((x /= base) != 0);
 6d5:	85 c0                	test   %eax,%eax
    x = xx;
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
 6d7:	88 14 34             	mov    %dl,(%esp,%esi,1)
 6da:	8d 56 01             	lea    0x1(%esi),%edx
  }while((x /= base) != 0);
 6dd:	75 e9                	jne    6c8 <printint+0x28>
  if(neg)
 6df:	85 ff                	test   %edi,%edi
 6e1:	74 07                	je     6ea <printint+0x4a>
    buf[i++] = '-';
 6e3:	c6 04 14 2d          	movb   $0x2d,(%esp,%edx,1)
 6e7:	8d 56 02             	lea    0x2(%esi),%edx

  while(--i >= 0)
 6ea:	8d 72 ff             	lea    -0x1(%edx),%esi
 6ed:	8d 76 00             	lea    0x0(%esi),%esi
    putc(fd, buf[i]);
 6f0:	0f be 14 34          	movsbl (%esp,%esi,1),%edx
 6f4:	89 d8                	mov    %ebx,%eax
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 6f6:	83 ee 01             	sub    $0x1,%esi
    putc(fd, buf[i]);
 6f9:	e8 72 ff ff ff       	call   670 <putc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 6fe:	83 fe ff             	cmp    $0xffffffff,%esi
 701:	75 ed                	jne    6f0 <printint+0x50>
    putc(fd, buf[i]);
}
 703:	83 c4 10             	add    $0x10,%esp
 706:	5b                   	pop    %ebx
 707:	5e                   	pop    %esi
 708:	5f                   	pop    %edi
 709:	c3                   	ret    
 70a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 710:	89 d0                	mov    %edx,%eax
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
 712:	31 ff                	xor    %edi,%edi
 714:	eb ac                	jmp    6c2 <printint+0x22>
 716:	8d 76 00             	lea    0x0(%esi),%esi
 719:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000720 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 720:	55                   	push   %ebp
 721:	57                   	push   %edi
 722:	56                   	push   %esi
 723:	53                   	push   %ebx
 724:	83 ec 2c             	sub    $0x2c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 727:	8b 5c 24 44          	mov    0x44(%esp),%ebx
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 72b:	8b 6c 24 40          	mov    0x40(%esp),%ebp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 72f:	0f b6 0b             	movzbl (%ebx),%ecx
 732:	84 c9                	test   %cl,%cl
 734:	0f 84 86 00 00 00    	je     7c0 <printf+0xa0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
 73a:	8d 44 24 48          	lea    0x48(%esp),%eax
{
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
 73e:	31 f6                	xor    %esi,%esi
  ap = (uint*)(void*)&fmt + 1;
 740:	89 44 24 1c          	mov    %eax,0x1c(%esp)
 744:	eb 1b                	jmp    761 <printf+0x41>
 746:	66 90                	xchg   %ax,%ax
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 748:	83 f9 25             	cmp    $0x25,%ecx
 74b:	74 7b                	je     7c8 <printf+0xa8>
        state = '%';
      } else {
        putc(fd, c);
 74d:	0f be d1             	movsbl %cl,%edx
 750:	89 e8                	mov    %ebp,%eax
 752:	e8 19 ff ff ff       	call   670 <putc>
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 757:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 75a:	0f b6 0b             	movzbl (%ebx),%ecx
 75d:	84 c9                	test   %cl,%cl
 75f:	74 5f                	je     7c0 <printf+0xa0>
    c = fmt[i] & 0xff;
    if(state == 0){
 761:	85 f6                	test   %esi,%esi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
 763:	0f b6 c9             	movzbl %cl,%ecx
    if(state == 0){
 766:	74 e0                	je     748 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 768:	83 fe 25             	cmp    $0x25,%esi
 76b:	75 ea                	jne    757 <printf+0x37>
      if(c == 'd'){
 76d:	83 f9 64             	cmp    $0x64,%ecx
 770:	0f 84 ba 00 00 00    	je     830 <printf+0x110>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
 776:	83 f9 70             	cmp    $0x70,%ecx
 779:	74 55                	je     7d0 <printf+0xb0>
 77b:	83 f9 78             	cmp    $0x78,%ecx
 77e:	66 90                	xchg   %ax,%ax
 780:	74 4e                	je     7d0 <printf+0xb0>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
 782:	83 f9 73             	cmp    $0x73,%ecx
 785:	74 71                	je     7f8 <printf+0xd8>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 787:	83 f9 63             	cmp    $0x63,%ecx
 78a:	0f 84 c3 00 00 00    	je     853 <printf+0x133>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 790:	83 f9 25             	cmp    $0x25,%ecx
        putc(fd, c);
 793:	ba 25 00 00 00       	mov    $0x25,%edx
 798:	89 e8                	mov    %ebp,%eax
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 79a:	74 12                	je     7ae <printf+0x8e>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 79c:	89 4c 24 18          	mov    %ecx,0x18(%esp)
 7a0:	e8 cb fe ff ff       	call   670 <putc>
        putc(fd, c);
 7a5:	8b 4c 24 18          	mov    0x18(%esp),%ecx
 7a9:	89 e8                	mov    %ebp,%eax
 7ab:	0f be d1             	movsbl %cl,%edx
 7ae:	e8 bd fe ff ff       	call   670 <putc>
      }
      state = 0;
 7b3:	31 f6                	xor    %esi,%esi
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 7b5:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 7b8:	0f b6 0b             	movzbl (%ebx),%ecx
 7bb:	84 c9                	test   %cl,%cl
 7bd:	75 a2                	jne    761 <printf+0x41>
 7bf:	90                   	nop
        putc(fd, c);
      }
      state = 0;
    }
  }
}
 7c0:	83 c4 2c             	add    $0x2c,%esp
 7c3:	5b                   	pop    %ebx
 7c4:	5e                   	pop    %esi
 7c5:	5f                   	pop    %edi
 7c6:	5d                   	pop    %ebp
 7c7:	c3                   	ret    
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
        state = '%';
 7c8:	be 25 00 00 00       	mov    $0x25,%esi
 7cd:	eb 88                	jmp    757 <printf+0x37>
 7cf:	90                   	nop
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 7d0:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 7d4:	b9 10 00 00 00       	mov    $0x10,%ecx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 7d9:	31 f6                	xor    %esi,%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 7db:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 7e2:	8b 10                	mov    (%eax),%edx
 7e4:	89 e8                	mov    %ebp,%eax
 7e6:	e8 b5 fe ff ff       	call   6a0 <printint>
        ap++;
 7eb:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 7f0:	e9 62 ff ff ff       	jmp    757 <printf+0x37>
 7f5:	8d 76 00             	lea    0x0(%esi),%esi
      } else if(c == 's'){
        s = (char*)*ap;
 7f8:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 7fc:	8b 38                	mov    (%eax),%edi
        ap++;
 7fe:	83 c0 04             	add    $0x4,%eax
 801:	89 44 24 1c          	mov    %eax,0x1c(%esp)
        if(s == 0)
 805:	85 ff                	test   %edi,%edi
 807:	74 64                	je     86d <printf+0x14d>
          s = "(null)";
        while(*s != 0){
 809:	0f b6 17             	movzbl (%edi),%edx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 80c:	31 f6                	xor    %esi,%esi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 80e:	84 d2                	test   %dl,%dl
 810:	0f 84 41 ff ff ff    	je     757 <printf+0x37>
 816:	66 90                	xchg   %ax,%ax
          putc(fd, *s);
 818:	0f be d2             	movsbl %dl,%edx
          s++;
 81b:	83 c7 01             	add    $0x1,%edi
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
 81e:	89 e8                	mov    %ebp,%eax
 820:	e8 4b fe ff ff       	call   670 <putc>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 825:	0f b6 17             	movzbl (%edi),%edx
 828:	84 d2                	test   %dl,%dl
 82a:	75 ec                	jne    818 <printf+0xf8>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 82c:	31 f6                	xor    %esi,%esi
 82e:	eb 85                	jmp    7b5 <printf+0x95>
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 830:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 834:	b1 0a                	mov    $0xa,%cl
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 836:	66 31 f6             	xor    %si,%si
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 839:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 840:	8b 10                	mov    (%eax),%edx
 842:	89 e8                	mov    %ebp,%eax
 844:	e8 57 fe ff ff       	call   6a0 <printint>
        ap++;
 849:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 84e:	e9 04 ff ff ff       	jmp    757 <printf+0x37>
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 853:	8b 44 24 1c          	mov    0x1c(%esp),%eax
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 857:	31 f6                	xor    %esi,%esi
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 859:	0f be 10             	movsbl (%eax),%edx
 85c:	89 e8                	mov    %ebp,%eax
 85e:	e8 0d fe ff ff       	call   670 <putc>
        ap++;
 863:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 868:	e9 ea fe ff ff       	jmp    757 <printf+0x37>
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
 86d:	bf 30 0a 00 00       	mov    $0xa30,%edi
 872:	eb 95                	jmp    809 <printf+0xe9>
 874:	90                   	nop
 875:	90                   	nop
 876:	90                   	nop
 877:	90                   	nop
 878:	90                   	nop
 879:	90                   	nop
 87a:	90                   	nop
 87b:	90                   	nop
 87c:	90                   	nop
 87d:	90                   	nop
 87e:	90                   	nop
 87f:	90                   	nop

00000880 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 880:	57                   	push   %edi
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 881:	a1 4c 0d 00 00       	mov    0xd4c,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
 886:	56                   	push   %esi
 887:	53                   	push   %ebx
 888:	8b 5c 24 10          	mov    0x10(%esp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
 88c:	8d 4b f8             	lea    -0x8(%ebx),%ecx
 88f:	90                   	nop
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 890:	39 c8                	cmp    %ecx,%eax
 892:	8b 10                	mov    (%eax),%edx
 894:	73 04                	jae    89a <free+0x1a>
 896:	39 d1                	cmp    %edx,%ecx
 898:	72 16                	jb     8b0 <free+0x30>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 89a:	39 d0                	cmp    %edx,%eax
 89c:	72 08                	jb     8a6 <free+0x26>
 89e:	39 c8                	cmp    %ecx,%eax
 8a0:	72 0e                	jb     8b0 <free+0x30>
 8a2:	39 d1                	cmp    %edx,%ecx
 8a4:	72 0a                	jb     8b0 <free+0x30>
static Header base;
static Header *freep;

void
free(void *ap)
{
 8a6:	89 d0                	mov    %edx,%eax
 8a8:	eb e6                	jmp    890 <free+0x10>
 8aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
 8b0:	8b 73 fc             	mov    -0x4(%ebx),%esi
 8b3:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 8b6:	39 d7                	cmp    %edx,%edi
 8b8:	74 18                	je     8d2 <free+0x52>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
 8ba:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
 8bd:	8b 50 04             	mov    0x4(%eax),%edx
 8c0:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 8c3:	39 f1                	cmp    %esi,%ecx
 8c5:	74 22                	je     8e9 <free+0x69>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
 8c7:	89 08                	mov    %ecx,(%eax)
  freep = p;
 8c9:	a3 4c 0d 00 00       	mov    %eax,0xd4c
}
 8ce:	5b                   	pop    %ebx
 8cf:	5e                   	pop    %esi
 8d0:	5f                   	pop    %edi
 8d1:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 8d2:	03 72 04             	add    0x4(%edx),%esi
 8d5:	89 73 fc             	mov    %esi,-0x4(%ebx)
    bp->s.ptr = p->s.ptr->s.ptr;
 8d8:	8b 10                	mov    (%eax),%edx
 8da:	8b 12                	mov    (%edx),%edx
 8dc:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
 8df:	8b 50 04             	mov    0x4(%eax),%edx
 8e2:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 8e5:	39 f1                	cmp    %esi,%ecx
 8e7:	75 de                	jne    8c7 <free+0x47>
    p->s.size += bp->s.size;
 8e9:	03 53 fc             	add    -0x4(%ebx),%edx
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
  freep = p;
 8ec:	a3 4c 0d 00 00       	mov    %eax,0xd4c
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 8f1:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 8f4:	8b 53 f8             	mov    -0x8(%ebx),%edx
 8f7:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
}
 8f9:	5b                   	pop    %ebx
 8fa:	5e                   	pop    %esi
 8fb:	5f                   	pop    %edi
 8fc:	c3                   	ret    
 8fd:	8d 76 00             	lea    0x0(%esi),%esi

00000900 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 900:	57                   	push   %edi
 901:	56                   	push   %esi
 902:	53                   	push   %ebx
 903:	83 ec 10             	sub    $0x10,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
 906:	8b 15 4c 0d 00 00    	mov    0xd4c,%edx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 90c:	8b 5c 24 20          	mov    0x20(%esp),%ebx
 910:	83 c3 07             	add    $0x7,%ebx
 913:	c1 eb 03             	shr    $0x3,%ebx
 916:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
 919:	85 d2                	test   %edx,%edx
 91b:	0f 84 9d 00 00 00    	je     9be <malloc+0xbe>
 921:	8b 02                	mov    (%edx),%eax
 923:	8b 48 04             	mov    0x4(%eax),%ecx
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
 926:	39 d9                	cmp    %ebx,%ecx
 928:	73 6e                	jae    998 <malloc+0x98>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 92a:	8d 3c dd 00 00 00 00 	lea    0x0(,%ebx,8),%edi
 931:	eb 0e                	jmp    941 <malloc+0x41>
 933:	90                   	nop
 934:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 938:	8b 02                	mov    (%edx),%eax
    if(p->s.size >= nunits){
 93a:	8b 48 04             	mov    0x4(%eax),%ecx
 93d:	39 cb                	cmp    %ecx,%ebx
 93f:	76 57                	jbe    998 <malloc+0x98>
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
 941:	3b 05 4c 0d 00 00    	cmp    0xd4c,%eax
 947:	89 c2                	mov    %eax,%edx
 949:	75 ed                	jne    938 <malloc+0x38>
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 94b:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
 951:	b8 00 80 00 00       	mov    $0x8000,%eax
    nu = PAGE;
 956:	be 00 10 00 00       	mov    $0x1000,%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 95b:	76 04                	jbe    961 <malloc+0x61>
 95d:	89 f8                	mov    %edi,%eax
 95f:	89 de                	mov    %ebx,%esi
    nu = PAGE;
  p = sbrk(nu * sizeof(Header));
 961:	89 04 24             	mov    %eax,(%esp)
 964:	e8 f3 fc ff ff       	call   65c <sbrk>
  if(p == (char*) -1)
 969:	83 f8 ff             	cmp    $0xffffffff,%eax
 96c:	74 1a                	je     988 <malloc+0x88>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
 96e:	89 70 04             	mov    %esi,0x4(%eax)
  free((void*)(hp + 1));
 971:	83 c0 08             	add    $0x8,%eax
 974:	89 04 24             	mov    %eax,(%esp)
 977:	e8 04 ff ff ff       	call   880 <free>
  return freep;
 97c:	8b 15 4c 0d 00 00    	mov    0xd4c,%edx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
 982:	85 d2                	test   %edx,%edx
 984:	75 b2                	jne    938 <malloc+0x38>
 986:	66 90                	xchg   %ax,%ax
        return 0;
  }
}
 988:	83 c4 10             	add    $0x10,%esp
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
 98b:	31 c0                	xor    %eax,%eax
  }
}
 98d:	5b                   	pop    %ebx
 98e:	5e                   	pop    %esi
 98f:	5f                   	pop    %edi
 990:	c3                   	ret    
 991:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
 998:	39 cb                	cmp    %ecx,%ebx
 99a:	74 1c                	je     9b8 <malloc+0xb8>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
 99c:	29 d9                	sub    %ebx,%ecx
 99e:	89 48 04             	mov    %ecx,0x4(%eax)
        p += p->s.size;
 9a1:	8d 04 c8             	lea    (%eax,%ecx,8),%eax
        p->s.size = nunits;
 9a4:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
 9a7:	89 15 4c 0d 00 00    	mov    %edx,0xd4c
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 9ad:	83 c4 10             	add    $0x10,%esp
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 9b0:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 9b3:	5b                   	pop    %ebx
 9b4:	5e                   	pop    %esi
 9b5:	5f                   	pop    %edi
 9b6:	c3                   	ret    
 9b7:	90                   	nop
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
 9b8:	8b 08                	mov    (%eax),%ecx
 9ba:	89 0a                	mov    %ecx,(%edx)
 9bc:	eb e9                	jmp    9a7 <malloc+0xa7>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 9be:	c7 05 4c 0d 00 00 50 	movl   $0xd50,0xd4c
 9c5:	0d 00 00 
    base.s.size = 0;
 9c8:	b8 50 0d 00 00       	mov    $0xd50,%eax
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 9cd:	c7 05 50 0d 00 00 50 	movl   $0xd50,0xd50
 9d4:	0d 00 00 
    base.s.size = 0;
 9d7:	c7 05 54 0d 00 00 00 	movl   $0x0,0xd54
 9de:	00 00 00 
 9e1:	e9 44 ff ff ff       	jmp    92a <malloc+0x2a>
